package com.whp.test;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

import java.lang.reflect.Field;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/5/21 9:42
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
	private String name ;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	//bean初始化前处理
	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if ("x".equals(beanName)) {
			Class<?> aClass = bean.getClass();
			Field[] declaredFields = aClass.getDeclaredFields();


			String name = declaredFields[0].getName();

		}

		return null;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		return null;
	}
}
